﻿using System.Web.Mvc;
using ZSoftInstagram.DataAccess;
using ZSoftInstagram.Domain.User;
using Microsoft.AspNet.Identity;
using System.Linq;

namespace ZSoftInstagram.UI.Web.Infrastructure.ViewBase
{
    public class RazorViewBase<T> : WebViewPage<T>
    {
        private static ApplicationUser _user;
        public ApplicationUser CurerntUser
        {
            get
            {
                using (var context = new ApplicationDbContext())
                {
                    if (_user == null)
                    {
                        var userId = User.Identity.GetUserId<int>();
                        _user = context.Users.First(u => u.Id == userId);
                    }

                    return _user;
                }
            }
        }

        public override void Execute()
        {
        }
    }
}
